package com.cssw.fyzb.wap.controller;

import com.cssw.fyzb.base.web.context.UserContext;
import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.dto.ResetPwdDto;
import com.cssw.fyzb.wap.model.dto.SendGiftDto;
import com.cssw.fyzb.wap.model.vo.GiftLogVo;
import com.cssw.fyzb.wap.model.vo.GiftStatisticsVo;
import com.cssw.fyzb.wap.model.vo.GiftVo;
import com.cssw.fyzb.wap.model.vo.PublicUserInfoVo;
import com.cssw.fyzb.wap.service.AnchorService;
import com.cssw.fyzb.wap.service.GiftService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wondream
 */
@RestController
@RequestMapping("/gift")
public class GiftController {

    @Autowired
    GiftService giftService;

    @ApiOperation(value = "获取礼物列表")
    @RequestMapping(value = "/listGift", method = RequestMethod.GET)
    @ResponseBody
    public AjaxPage<GiftVo> listGift() {
        return giftService.listGift();
    }

    @ApiOperation("赠送礼物")
    @ApiImplicitParam(name = "dto", value = "赠送礼物", dataType = "SendGiftDto")
    @PostMapping("sendGift")
    public AjaxData<GiftVo> sendGift(@RequestBody SendGiftDto dto) {
        return giftService.sendGift(
                UserContext.getUserId(), dto.getToUserId(), dto.getLiveId(), dto.getGiftId()
        );
    }

    @ApiOperation(value = "用户赠送礼物列表")
    @RequestMapping(value = "/listGiftLog", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @ResponseBody
    public AjaxPage<GiftLogVo> listGiftLog(int pageNumber, int pageSize) {
        return giftService.listGiftLog(UserContext.getUserId(), pageNumber, pageSize);
    }

    @ApiOperation(value = "主播收到礼物列表")
    @RequestMapping(value = "/listReceivedGift", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @ResponseBody
    public AjaxPage<GiftVo> listReceivedGift(int pageNumber, int pageSize) {
        return giftService.listReceivedGift(UserContext.getUserId(), pageNumber, pageSize);
    }

    @ApiOperation(value = "用户赠送礼物列表")
    @RequestMapping(value = "/listSendGift", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @ResponseBody
    public AjaxPage<GiftVo> listSendGift(int pageNumber, int pageSize) {
        return giftService.listSendGift(UserContext.getUserId(), pageNumber, pageSize);
    }

    @ApiOperation(value = "主播收到礼物统计(根据礼物id)")
    @RequestMapping(value = "/receivedGiftStatistics", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @ResponseBody
    public AjaxPage<GiftStatisticsVo> receivedGiftStatistics(int pageNumber, int pageSize) {
        return giftService.receivedGiftStatistics(UserContext.getUserId(), pageNumber, pageSize);
    }
}
